package com.ThreadState;
//守护线程  理解——> 陪伴线程 主线程停止 线程就停止
//thread.setDaemon(true); true为守护线程 false用户线程
public class ThreadDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();
        new Thread(you).start();
        Thread thread = new Thread(god);
        thread.setDaemon(true);
        thread.start();

    }
}
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("性感上帝,在线发牌");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 500; i++) {
            System.out.println("今天也是美好的一天");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("goodbye -World");
    }
}
